home *** CD-ROM | disk | FTP | other *** search
/ FM Towns: Free Software Collection 6 / FM Towns Free Software Collection 6.iso / t_os / catlog / source / clip.c < prev    next >
C/C++ Source or Header  |  1993-07-08  |  7KB  |  237 lines

  1. /*
  2.     NIFTYのLOG整理                clip.c
  3.                     by GHH01217 山先
  4.     $Header: CLIP.Cv  1.2  93/02/12 22:44:20  山先  Exp $
  5. */
  6.  
  7. #include    "log.h"
  8.  
  9. #define        TEST    1
  10. #undef        TEST
  11.  
  12. /****************************************************************************
  13. >123456789 123456789 123456789 
  14. >クリッピングサービス    CLIP
  15. *****************************************************************************/
  16. int        isCLIPFirstLine()
  17. {
  18.     IFPStrEqu("クリッピングサービス    CLIP",28)    return( YES );
  19. /*
  20.     IFPStrEqu("番号  提供日付        題名",26)        return( YES );
  21. */
  22.     return( NO );
  23. }
  24.  
  25. /****************************************************************************
  26. >          1         2         3         4         5
  27. > 123456789 123456789 123456789 123456789 123456789 123456789 123456789 1234
  28. >番号  提供日付        題名
  29. >  1    1/08 15:09 時: ◎CDROMで特許出願公開
  30. >  2    1/08 12:01 時: ◎松下、米ベンチャー企業に出資
  31. *****************************************************************************/
  32. static    int        isCLIPLine_sub( const char *str , int len )
  33. {
  34.     if ( len < 24 )                        return( NO );
  35.     if ( ! isdigit( str[  2 ] ) )        return( NO ); /* 番号 */
  36.     if ( ! isdigit( str[  7 ] ) )        return( NO ); /* 月 */
  37.     if ( str[   8 ] != '/' )            return( NO );
  38.     if ( check_digit(  9 , 10 ) == NO )    return( NO ); /* 日 */
  39.     if ( str[  11 ] != ' ' )            return( NO );
  40.     if ( check_digit( 12 , 13 ) == NO )    return( NO ); /* 時 */
  41.     if ( str[  14 ] != ':' )            return( NO );
  42.     if ( check_digit( 15 , 16 ) == NO )    return( NO ); /* 分 */
  43.     if ( str[  17 ] != ' ' )            return( NO );
  44.     if ( str[  21 ] != ' ' )            return( NO );
  45.     return( YES );
  46. }
  47.  
  48. int        isCLIPStr( const char *str )
  49. {
  50.     return( isCLIPLine_sub( str , strlen( str ) ) );
  51. }
  52.  
  53. int        isCLIPLine()
  54. {
  55.     return( isCLIPLine_sub( PresentStrPtr , PresentStrLen ) );
  56. }
  57.  
  58. /****************************************************************************
  59. >          1         2         3         4         5
  60. > 123456789 123456789 123456789 123456789 123456789 123456789 123456789 1234
  61. >[1993-01-08-15:09]
  62. >続き (改行で次文書 E:終了)
  63. >表示終了
  64. *****************************************************************************/
  65. int        isCLIPEnd()
  66. {
  67.     int        len;
  68.     char    *str;
  69.  
  70.     IFPStrEqu("続き (改行で次文書 E:終了)",27)        return( YES );
  71.     IFPStrEqu("表示終了",8)                            return( YES );
  72.  
  73.     if ( isCLIPFirstLine() == YES )                    return( YES );
  74.     if ( isCLIPLine() == YES )                        return( YES );
  75.  
  76.     return( NO );
  77.  
  78.     str = PresentStrPtr;    len = PresentStrLen;
  79.     if ( len != 18 )                    return( NO );
  80.     if ( str[   0 ] != '[' )            return( NO );
  81.     if ( check_digit(  1 ,  4 ) == NO )    return( NO ); /* 年 */
  82.     if ( str[   5 ] != '-' )            return( NO );
  83.     if ( check_digit(  6 ,  7 ) == NO )    return( NO ); /* 月 */
  84.     if ( str[   8 ] != '-' )            return( NO );
  85.     if ( check_digit(  9 , 10 ) == NO )    return( NO ); /* 日 */
  86.     if ( str[  11 ] != '-' )            return( NO );
  87.     if ( check_digit( 12 , 13 ) == NO )    return( NO ); /* 時 */
  88.     if ( str[  14 ] != ':' )            return( NO );
  89.     if ( check_digit( 15 , 16 ) == NO )    return( NO ); /* 分 */
  90.     if ( str[  17 ] != ']' )            return( NO );
  91.     return( YES );
  92. }
  93.  
  94. static    void    check_clip_skip()
  95. {
  96.     forever {
  97.         IFPStrEqu2(">",2)                    break;
  98.         GET_LINE;
  99.     };
  100.     GET_LINE;    /* 先読み */
  101. }
  102.  
  103. void    check_clip_main()
  104. {
  105.     print_start_line();    /* *PresentStrPtr を YELLOW で表示 */
  106.     GET_LINE;
  107.     check_clip_skip();
  108.     check_clip_skip();
  109.     check_skip_useless_line();
  110.     while (    isCLIPLine() == YES ) {
  111.         check_pool_delete_start = PresentStrPtr;
  112.         /* フォーラム名 */
  113.         strcpy( forum_name , "CLIP" );                    /* フォーラム名 */
  114.         kaigishitsu_number = CLIP;                        /* 会議室番号 */
  115.         hatsugen_number = atoi( PresentStrPtr );        /* 発言番号 */
  116.         set_hatsugen_date_clip( PresentStrPtr );        /* 日付 sub.c */
  117.         comment_number = 0;                                /* コメント先番号 */
  118.         *collect_id = '\0';                                /* 発言の収集 */
  119.         present_str_copy( forum_name_line );
  120.         *forum_sub_name_line = '\0';
  121.         check_save_start_sub();
  122.         GET_LINE;    check_set_lib_number();
  123.         while ( isCLIPLine() != YES ) {
  124.             GET_LINE2 break;    check_set_lib_number();
  125.             if ( check_check_end() == YES ) break;
  126.         };
  127.         /* 本文を書き出す */
  128.         catlog_fwrite();
  129.         check_skip_useless_line();
  130.     };
  131. }
  132.  
  133. /*********************************************************************/
  134. /***************************  第3段階  ******************************/
  135. /*********************************************************************/
  136.  
  137. static    int        is_clip_index( )
  138. {
  139.     int        sw;
  140.     FILE    *fp;
  141.  
  142.     set_index_file_name( "CLIP" );        /* file.c */
  143.     sw = NO;
  144.     if ( ( fp = fopen( file_name , "r" ) ) != NULL ) {
  145.         while( fgets( str , LINE , fp ) != NULL ) {
  146.             without_crlf( str );
  147.             if ( strcmp( str + 3 , forum_name_line + 3 ) == 0 ) {
  148.                 sw = YES;
  149.                 break;
  150.             };
  151.         };
  152.     };
  153.     fclose( fp );
  154.     return( sw );
  155. }
  156.  
  157. static    void    catlog_clip_skip_data()
  158. {
  159.     while ( strncmp( str , "*****log整理" , 12 ) != 0 ) {
  160.         if ( fgets( str , LINE , catlog_fpi ) == NULL ) break;
  161.     };
  162. }
  163.  
  164. static    void    catlog_clip_append_index( )
  165. {
  166.     FILE    *index_fpo;
  167.  
  168.     set_index_file_name( "CLIP" );        /* file.c */
  169.     if ( ( index_fpo = fopen( file_name , "a" ) ) == NULL ) {
  170.         error_open_file( "catlog_clip_append_index()" );
  171.         error_end();
  172.     };
  173.     fprintf( index_fpo , "%s\n" , forum_name_line );
  174.     fclose( index_fpo );
  175. }
  176.  
  177. void    catlog_clip_main( char *catlog_findfirst_path , const char *file )
  178. {
  179.     int        sw , cr_sw;
  180.  
  181.     *forum_sub_name_line = '\0';
  182.  
  183.     /* 入力ファイルのオープン */
  184.     catlog_fpi = fopen( file , "r" );
  185.     fgets( str , LINE , catlog_fpi );    /* 先読み */
  186.     sw = TRUE;
  187.     while ( strncmp( str , "*****log整理" , 12 ) == 0 ) {
  188.         strcpy( partition_line , str );
  189.         fgets( str , LINE , catlog_fpi );        /* ID名 フォーラム名 */
  190.         fgets( str , LINE , catlog_fpi );        /* 会議室番号 */
  191.         fgets( str , LINE , catlog_fpi );        /* 発言番号 */
  192.         fgets( str , LINE , catlog_fpi );        /* 日付 */
  193.         fgets( str , LINE , catlog_fpi );        /* コメント番号 */
  194.         fgets( str , LINE , catlog_fpi );        /* ID収集? */
  195.         fgets( str , LINE , catlog_fpi );        /* <………>   FFMHOB */
  196.             without_crlf( str );
  197.             /* フォーラム名の設定。 null の場合もある */
  198.             strcpy( forum_name_line , str );
  199.         fgets( str , LINE , catlog_fpi );        /* forum_sub_name_line */
  200.  
  201.         /* 登録済かチェック */
  202.         if ( is_clip_index( ) == YES ) {
  203.             catlog_clip_skip_data();        continue;
  204.         };
  205.  
  206.         /* インデックスに登録する */
  207.         catlog_clip_append_index( catlog_findfirst_path );
  208.  
  209.         /* catlog_fpo をオープンする */
  210.         open_save_data_file( 0 , NO );
  211.  
  212.         /* *****log整理~~を出力する */
  213.         if ( no_partition_line_sw != YES ) {
  214.             fprintf( catlog_fpo , "%s" , partition_line );
  215.         };
  216.  
  217.         fgets( str , LINE , catlog_fpi );    /* 先読み */
  218.         forever {
  219.             fprintf( catlog_fpo , "%s" , str );
  220.             if ( *str == '\n' )    {    cr_sw = YES;
  221.             } else {                cr_sw = NO;
  222.             };
  223.             if ( fgets( str , LINE , catlog_fpi ) == NULL ) {
  224.                 sw = FALSE;
  225.                 break;
  226.             };
  227.             if ( strncmp( str , "*****log整理" , 12 ) == 0 )    break;
  228.         };
  229.         if ( cr_sw == NO ) fputc( '\n' , catlog_fpo );
  230.         fclose( catlog_fpo );
  231.         hatugen_su++;
  232.         if ( sw == FALSE )                                        break;
  233.     };
  234.     fclose( catlog_fpi );
  235. }
  236.  
  237.